<!-- 5:js实现四则运算：输入两个数，计算他们的加减乘除 --><!-- （np版） -->
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>四则运算</title>
    <script type="text/javascript">
      function account(){
        var num1 = prompt("请输入第一个值：","");
        // alert(typeof(num1));
        var num11 = parseInt(num1);

        var num2 = prompt("请输入第二个值:","");
        var num22 = parseInt(num2);

        var ysf = prompt("请输入运算符:","");
        var result ;
        switch(ysf){
          case "+":
            result = num11 + num22;
            break;
          case "-":
            result = num11 - num22;
            break;
          case "*":
            result = num11 * num22;
            break;
          case "/":
            if(num22!=0){
              result = num11 / num22;
            }else{
              alert("除数不能为0");
            }
            break;
        }
        document.write(result+"<br />");

      }
    </script>
  </head>
  <body>
    <button onclick="account()">点击计算两个数的值</button>  
  </body>
</html>